﻿
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外出请假登记</title>
<link href="/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/css/cb.css" rel="stylesheet" type="text/css" />
<link href="/css/n.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css"
	href="/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/easyui/demo/demo.css" />
<link rel="stylesheet" type="text/css"
	href="/js/laypage/skin/laypage.css" />

<script type="text/javascript" src="/easyui/jquery.min.js"></script>
<script src="/js/vue/vue.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/laypage/laypage.js"></script>
<script type="text/javascript" src="/laydate/laydate.js"></script>
<script type="text/javascript" src="/js/examine.js"></script>
	
	
</head>
<body>
<div id="app">
	<table width="99%" border="0" align="center" cellpadding="0"
		cellspacing="0">
		<tr>
			<td width="1%" align="left"
				background="${request.contextPath}/images/b2.jpg"><img
				src="${request.contextPath}/images/b1.jpg" width="10" height="26" /></td>
			<td width="68%" background="${request.contextPath}/images/b2.jpg"><table
					width="124" border="0" align="left" cellpadding="0" cellspacing="0">
					<tr>
						<td width="20" align="left"><img
							src="${request.contextPath}/images/tz.gif" width="10" height="16" /></td>
						<td width="104" align="left" class="biao">查找外出请假表信息</td>
					</tr>
				</table></td>
			<td width="31%" align="right"
				background="${request.contextPath}/images/b2.jpg"><img
				src="${request.contextPath}/images/b3.jpg" width="9" height="26" /></td>
		</tr>
	</table>
	<table width="99%" border="0" align="center" cellpadding="3"
		cellspacing="1" bgcolor="#AEDEF4">
		<tr>
			<td align="center" bgcolor="#E2F7FE">
				<form id="form1" name="form1" method="post" action="">
					<table width="80%" border="0" cellspacing="1" cellpadding="3">
						<tr>
							<td width="10%" align="right">矫正单位:</td>
							<td width="10%" align="left"><input name="unit" type="text"
								id="unit" size="15" /></td>
							<td width="10%" align="right">姓名:</td>
							<td width="10%" align="left"><input name="name" type="text"
								id="name" size="15" /></td>
							<td width="10%" align="right">请假日期:</td>
							<td width="10%" align="left"><input id="date"
								placeholder="请输入日期" class="laydate-icon" onclick="laydate()" /></td>
							<td width="10%" align="left"><input type="button"
								name="query" onclick="queryfind()" value="查找" /></td>
							<td width="10%" colspan="2" align="right"><input
								type="button" onclick="addEvent()" name="" value="增加记录" /> <input
								type="button" name="" value="导出Excle" /></td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
	</table>

	<table width="50%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="5"></td>
		</tr>
	</table>
	<table width="99%" border="0" align="center" cellpadding="0"
		cellspacing="0">
		<tr>
			<td width="1%" align="left"
				background="${request.contextPath}/images/b2.jpg"><img
				src="${request.contextPath}/images/b1.jpg" width="10" height="26" /></td>
			<td width="68%" background="${request.contextPath}/images/b2.jpg"><table
					width="124" border="0" align="left" cellpadding="0" cellspacing="0">
					<tr>
						<td width="20" align="left"><img
							src="${request.contextPath}/images/tz.gif" width="10" height="16" /></td>
						<td width="104" align="left" class="biao">外出请假单列表</td>
					</tr>
				</table></td>
			<td width="31%" align="right"
				background="${request.contextPath}/images/b2.jpg"><img
				src="${request.contextPath}/images/b3.jpg" width="9" height="26" /></td>
		</tr>
	</table>
	<table width="99%" border="0" align="center" cellpadding="3"
		cellspacing="1" bgcolor="#AEDEF4" style="border: 1px solid #AEDEF4"
		id="app">
		<tr><td width="50px" height="25" align="center" bgcolor="#EFFBFE">
					<input type="checkbox" id="allcheck" name="allcheck"/>
					</td>
			<td width="5%" height="25" align="center" bgcolor="#EFFBFE">序号</td>
			<td align="center" bgcolor="#EFFBFE">矫正单位</td>
			<td align="center" bgcolor="#EFFBFE">姓名</td>
			<td align="center" bgcolor="#EFFBFE">目的地</td>
			<td align="center" bgcolor="#EFFBFE">请假事由</td>
			<td align="center" bgcolor="#EFFBFE">起始日期</td>
			<td align="center" bgcolor="#EFFBFE">截止日期</td>
			<td align="center" bgcolor="#EFFBFE">状态</td>
			<td align="center" bgcolor="#EFFBFE">管理操作</td>
		</tr>
		<tr v-for="(item,index) in result"
			onmouseout="this.style.backgroundColor='#ffffff'" bgcolor="#ffffff"
			onmouseover="this.style.backgroundColor='#E6F2FF'">
           <td height="25" align="center" ><input type="checkbox"  name="check" :value="item.id" />
					</td>
			<td height="25" align="center">{{index+1}}</td>
			<td align="center">{{item.deptname}}</td>
			<td align="center">{{item.name}}</td>
			<td align="center">{{item.bourn}}</td>
			<td align="center">{{item.reason}}</td>
			<td align="center">{{item.startdate}}</td>
			<td align="center">{{item.enddate}}</td>
			<td align="center">已请假</td>
			<td align="left">
				<div align="left" style="padding-left: 5px">
					<div align="center">
						<input type="button" @click="checkEvent(item.id)" name="query"
							value="查看" /> <input type="button" @click="editEvent(item.id)"
							name="" value="修改" /> <input type="button"
							@click="delEvent(item.id)" name="" value="删除" />
					</div>
				</div>
			</td>
		</tr>

		<tr>
			<td colspan="6" align="center">
				<div id="pagediv"></div>
			</td>
		</tr>
	</table>

	<!-- 增加外出请假条弹出框 -->
	<div id="addleave" align="center"></div>
	<!-- 查看外出请假条弹出框 -->
	<div id="checkleave"></div>
	<!-- 修改外出请假条弹出框 -->
	<div id="editleave"></div>
</div>
</body>
<!--js 代码控制增删改查弹出层-->
<script>
	var app = new Vue({
		el : '#app',
		data : {
			result : []
		}
	});

	//模糊查询
	var getPageList = function(curr) {
		$.ajax({
			type : "post",
			dataType : "json",
			url : "/leave/getlike",
			data : {
				pageNum : curr || 1,
				pageSize : 2,
				cunit : $("#unit").val(),
				cname : $("#name").val(),
				cdate : $("#date").val()
			},
			//显示分页
			success : function(msg) {
				app.result = msg.data[0].result;
				console.log(msg.data[0]);
				laypage({
					cont : 'pagediv', //容器。值支持id名、原生dom对象，jquery对象,
					pages : msg.data[0].totalPage, //总页数
					first : "首页",
					last : "尾页",
					skip : true, //是否开启跳页
					skin : '#5675A2',
					curr : curr || 1, //当前页
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							getPageList(obj.curr);
						}
					}
				});
			}
		});
	}
	//获取列表
	getPageList();
	//模糊查询外出事件
	var queryfind = function() {
		getPageList();
	}

	
	//增加外出请假条登记记录
	var addEvent = function() {
		$('#addleave').dialog({
			title : "增加外出请假条",
			width : 720,
			height : 400,
			padding : 10,
			closed : false,
			cache : false,
			href : '/leave/addskip',//增加窗口跳转
			modal : true,
			buttons : [ {
				text : '保存',
				iconCls : 'icon-ok',
				handler : function() {
					$.ajax({
						type : "POST",
						dataType : "json",
						url : "${request.contextPath}/leave/add",
						data : {
							"jids" : $('#jids').val(),
							"pids" : $('#pids').val(),
							"dates" : $('#leavedate').val(),
							"bourn" : $('#bourn').val(),
							"reason" : $('#reason').val(),
							"target" : $('#target').val(),
							"relation" : $('#relation').val(),
							"zz_status" : $('#zz_status').val(),
							"org" : $('#org').val(),
							"address" : $('#address').val(),
							"startdates" : $('#startdate').val(),
							"enddates" : $('#enddate').val(),
							"location" : $('#location').val(),
							"remark" : $('#remark').val()
						},
						success : function(result) {
							$.messager.alert({
								title : '消息',
								msg : '增加成功！',
								icon : 'info'
							});
							getPageList();
							$('#addleave').dialog('close');
						}
					});
				}
			}, {
				text : '关闭',
				handler : function() {
					$('#addleave').dialog('close');
				}

			} ]
		});
	}
	
	
	
	
	
	
	//修改外出请假登记记录
	var editEvent = function(id) {
		$('#editleave').dialog({
			title : '修改外出请假条',
			width : 720,
			height : 400,
			closed : false,
			cache : false,
			href : '/leave/detail?sort=edit&id='+id,//修改页面跳转
			modal : true,
			buttons : [ {
				text : '保存',
				iconCls : 'icon-ok',
				handler : function() {
					$.ajax({
						type : "get",
						dataType : "json",
						url : "/leave/edit",
						data : {
							"id":id,
							"bourn" : $('#editbourn').val(),
							"reason" : $('#editreason').val(),
							"target" : $('#edittarget').val(),
							"relation" : $('#editrelation').val(),
							"zz_status" : $('#editzz_status').val(),
							"org" : $('#editorg').val(),
							"address" : $('#editaddress').val(),
							"dates" : $('#editdate').val(),
							"startdates" : $('#editstartdate').val(),
							"enddates": $('#editenddate').val(),
							"location" : $('#editlocation').val(),
							"remark" : $('#editremark').val()
						},
						success : function(result) {
							$.messager.alert({
								title : '消息',
								msg : '修改成功!',
								icon : 'info'
							});
							getPageList();
							$('#editleave').dialog('close');
						}
					});
				}
			}, {
				text : '关闭',
				handler : function() {
					$('#editleave').dialog('close');
				}
			} ]
		});
	}

	//查看外出请假登记详情
	var checkEvent = function(id) {
	console.log(id);
		$('#checkleave').dialog({
			title : '查看外出请假登记',
			width : 720,
			height : 400,
			closed : false,
			cache : false,
			href : '/leave/detail?sort=look&id='+id,
			modal : true,
			buttons:[{
			      text:'关闭',
			      handler:function(){
			            $('#checkleave').dialog('close');
			      }
			}]
		});
	}

	//删除外出请假登记
	var delEvent = function(id) {
		$.messager.confirm('提示框', '你确定要删除吗?', function(res) {
			if (res) {
				//确认删除
				$.ajax({
					url : "/leave/del",
					data : {
							id:id
					},
					type : "get",
					datatype : "json",
					success : function(result) {
						if (result.code == 0) {
							$.messager.alert({
								title : '消息',
								msg : '删除成功!',
								icon : 'info'
							});
							getPageList();//更新分页
						} else {
							$.messager.alert({
								title : '消息',
								msg : '删除失败!',
								icon : 'info'
							});
						}
					}
				});
			} else {
				//取消删除
			}
		})
	}

</script>
</html>